import React from 'react'
import * as UI from "antd-mobile"
import * as ICON from "antd-mobile-icons"
//引入接口请求
import request from '@/services/request'
//引入cookies
import cookies from 'react-cookies'


//React命名空间下创建自定义属性
React.UI = UI
React.ICON = ICON
React.request = request
React.cookies = cookies

React.business = React.cookies.load('business') ?? {}
// 成功和失败提醒方法
React.toast = (msg: string, callback?: any, type?: string) =>
{
  React.UI.Toast.show({
    icon: type ? type : 'success',
    content: msg,
    duration: 1500,
    afterClose: () => 
    {
        if(!callback) return;

        if(typeof callback === "string") callback === "back" ? React.navigate(-1) : React.navigate(callback)
        else callback()
    }
})
}

// 不需要登录的界面
React.RouterRules = [
  '/',
  '/business/login',
  '/coupon/info',
  '/room/info'
]
export default {}
